<?php

namespace Modules\Shop\Entities;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    //protected $fillable = ['title','category_id','author','content','thumb','click','iscommend'];
    //设置不允许批量填充的字段数据,那么没再数组内的就都允许
    protected $guarded = ['file'];

    /**
     * 模型关联
     * 模型关联其实就是用当前模型去关联另外一个模型
     * 果被关联模型中的关联字段是当前模型的名称加上_id,并且主键是ID时，两者都可以忽略
     */
    public function category(){
        return $this->belongsTo(Category::class);
    }
    public function comment(){
        return $this->hasMany(Comment::class,'article_id','id');
    }
}
